from rest_framework import serializers
from workflow.models import Workflow, WorkflowRole, WorkflowApprovalNode, Task, AuditRecord

class WorkflowSerializer(serializers.ModelSerializer):
    class Meta:
        model = Workflow
        fields = '__all__'

class WorkflowRoleSerializer(serializers.ModelSerializer):
    role_list = serializers.ListField(write_only=True)

    class Meta:
        model = WorkflowRole
        fields = '__all__'

class WorkflowApprovalNodeSerializer(serializers.ModelSerializer):
    class Meta:
        model = WorkflowApprovalNode
        fields = '__all__'

class TaskSerializer(serializers.ModelSerializer):
    workflow_name = serializers.CharField(source="workflow.name", read_only=True)
    admin_name = serializers.CharField(source="admin.name", read_only=True)
    class Meta:
        model = Task
        fields = '__all__'

class AuditRecordSerializer(serializers.ModelSerializer):
    class Meta:
        model = AuditRecord
        fields = '__all__'
